package actors

import (
	"engine"
	"engine/stream/net/http"
	"gitee.com/ameise84/e3dds"
	"gitee.com/ameise84/e3utils/uuid"

	"servers/app/node/api/common"
)

func init() {
	engine.RegisterHttpPostRouter(_gService, "/backend-api/modify-player-ctrl", toolsModifyPlayerCtrl)
	engine.RegisterHttpPostRouter(_gService, "/backend-api/add-auto-ctrl", toolsAddAutoCtrl)
	engine.RegisterHttpPostRouter(_gService, "/backend-api/modify-auto-ctrl", toolsModifyAutoCtrl)
	engine.RegisterHttpPostRouter(_gService, "/backend-api/del-auto-ctrl", toolsDelAutoCtrl)
	engine.RegisterHttpPostRouter(_gService, "/backend-api/modify-jackpot-score", toolsModifyJackpotScore)
	engine.RegisterHttpPostRouter(_gService, "/backend-api/modify_limit-score", toolsModifyBusinessLimitScore)
	engine.RegisterHttpPostRouter(_gService, "/backend-api/kick-user", toolsKickUser)
	engine.RegisterHttpGetRouter(_gService, "/backend-api/get-game-log-info", toolsGetGameLogInfo)
	engine.RegisterHttpGetRouter(_gService, "/demo-api/create", toolsCreate)
	engine.RegisterHttpGetRouter(_gService, "/demo-api/get-game-list", toolsGetGameList)
	engine.RegisterHttpGetRouter(_gService, "/demo-api/get-player-score", toolsGetPlayerScoreInfo)
	engine.RegisterHttpGetRouter(_gService, "/demo-api/get-game-url", toolsGetGameURL)
	engine.RegisterHttpPostRouter(_gService, "/demo-api/use-bank", toolsUseBank)
}

func toolsModifyPlayerCtrl(behavior e3dds.Behavior, req e3dds.Request) bool {
	httpCtx := req.Context().(*http.Context)
	params := httpCtx.AllQuery()
	common.OnModifyPlayerCtrl(behavior, req, params)
	return true
}

func toolsAddAutoCtrl(behavior e3dds.Behavior, req e3dds.Request) bool {
	httpCtx := req.Context().(*http.Context)
	params := httpCtx.AllQuery()
	common.OnAddAutoCtrl(behavior, req, params)
	return true
}

func toolsModifyAutoCtrl(behavior e3dds.Behavior, req e3dds.Request) bool {
	httpCtx := req.Context().(*http.Context)
	params := httpCtx.AllQuery()
	common.OnModifyAutoCtrl(behavior, req, params)
	return true
}

func toolsDelAutoCtrl(behavior e3dds.Behavior, req e3dds.Request) bool {
	httpCtx := req.Context().(*http.Context)
	params := httpCtx.AllQuery()
	common.OnDelAutoCtrl(behavior, req, params)
	return true
}

func toolsModifyJackpotScore(behavior e3dds.Behavior, req e3dds.Request) bool {
	return true
}

func toolsModifyBusinessLimitScore(behavior e3dds.Behavior, req e3dds.Request) bool {
	return true
}

func toolsKickUser(behavior e3dds.Behavior, req e3dds.Request) bool {
	return true
}

func toolsGetGameLogInfo(behavior e3dds.Behavior, req e3dds.Request) bool {
	httpCtx := req.Context().(*http.Context)
	params := httpCtx.AllQuery()
	common.OnGetGameLogInfo(behavior, req, params)
	return true
}

func toolsCreate(behavior e3dds.Behavior, req e3dds.Request) bool {
	httpCtx := req.Context().(*http.Context)
	params := httpCtx.AllQuery()
	common.OnCreateAccount(behavior, req, params)
	return true
}

func toolsGetGameURL(behavior e3dds.Behavior, req e3dds.Request) bool {
	httpCtx := req.Context().(*http.Context)
	params := httpCtx.AllQuery()
	common.OnGetGameURL(behavior, req, params, _gDefaultAes)
	return true
}

func toolsGetPlayerScoreInfo(behavior e3dds.Behavior, req e3dds.Request) bool {
	httpCtx := req.Context().(*http.Context)
	params := httpCtx.AllQuery()
	common.OnGetPlayerScoreInfo(behavior, req, params)
	return true
}

func toolsGetGameList(behavior e3dds.Behavior, req e3dds.Request) bool {
	httpCtx := req.Context().(*http.Context)
	params := httpCtx.AllQuery()
	common.OnGetGameList(behavior, req, params)
	return true
}

func toolsUseBank(behavior e3dds.Behavior, req e3dds.Request) bool {
	httpCtx := req.Context().(*http.Context)
	params := httpCtx.AllQuery()
	params["order"] = uuid.New()
	if _, ok := params["flag"]; !ok {
		params["flag"] = "false"
	}
	common.OnUseBank(behavior, req, params)
	return true
}
